package org.bugjail.data;

import java.util.Map;

/**
 * This class represents an user of the system.
 * 
 * @author Edwin Carlo
 * 
 */
public class Person {

	// Private
	private int id;
	private String name;
	private String login;
	private String password;
	private String mail;
	private Map<Project, AccessLevel> projects;
	private int language;
	private Project currentProject;

	// Public

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Person) {
			Person p = (Person) obj;
			return (p.id == this.id);
		} else {
			return false;
		}
	}
	
	/**
	 * Return an integer representation of the language used by the user.
	 */
	public int getLanguage() {
		return language;
	}

	/**
	 * Method to change the language of the user, represented by an integer
	 * value.
	 * @param language
	 */
	public void setLanguage(int language) {
		this.language = language;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * Retrieve the projects that the user has access.
	 * @return The projects that the user has access and the correspondent
	 * access levels, that will define which permissions the user will have.
	 */
	public Map<Project, AccessLevel> getProjects() {
		return projects;
	}

	public void setProjects(Map<Project, AccessLevel> projects) {
		this.projects = projects;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	/**
	 * Method to retrieve the current project of the user. It will be used to 
	 * store the last accessed project. The intention is to be easier when enter
	 * in the system, to start at least in the same project that the user was in
	 * the last login.
	 * @return The current user project
	 */
	public Project getCurrentProject() {
		return currentProject;
	}

	public void setCurrentProject(Project currentProject) {
		this.currentProject = currentProject;
	}
}